<template>
  <el-form
    style="width:400px;"
    label-position="top"
    :model="discussModel"
    label-width="80px"
  >
    <el-form-item label="昵称">
      <el-input v-model="discussModel.discusser"></el-input>
    </el-form-item>

    <el-form-item label="内容">
      <el-input type="textarea" v-model="discussModel.concent"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="submit">发表讨论</el-button>
      <el-button>取消</el-button>
    </el-form-item>
  </el-form>
</template>

<script setup>
import { reactive, watch } from 'vue'
// 数据列表的状态
import dataListControl from '../control/data-list'
// 表单管理
import discussFromControl from '../control/data-form'

// 获取操作函数：注入状态，博文列表数组，
const { dataListState } = dataListControl('discussList')
// 表单管理
const { discussModel, addNewDiscuss } = discussFromControl()

console.log('discussModel', discussModel)
// 日期格式化
const dateFormat = dayjs

// 组件的属性
const props = defineProps({
  id: String
})

// 发布讨论
const submit = () => {
  discussModel.blogId = props.id
  addNewDiscuss().then((id) => {
    // 通知列表
    dataListState.isReload = !dataListState.isReload
  })
}

</script>
